FROM deeppavlov/deeppavlov:1.2.0-gpu

RUN apt-get update && apt-get install git -y

ARG CONFIG
ARG SERVICE_PORT
ARG SED_ARG=" | "

ENV CONFIG=$CONFIG
ENV SERVICE_PORT=$SERVICE_PORT

COPY ./requirements.txt /src/requirements.txt
COPY . /src
WORKDIR /src

RUN pip freeze | grep deeppavlov && \
    pip install -r /src/requirements.txt && \
    python -m deeppavlov install $CONFIG && \
    python -m spacy download en_core_web_sm

RUN sed -i "s|$SED_ARG|g" "$CONFIG"

CMD gunicorn --workers=1 --timeout 500 server:app -b 0.0.0.0:8078
